(function() {
	$('#admin-poll-list').live('pageinit', function(event) {
		$('.poll-opt').parent().click(vote_option);
	});

	function vote_option()// by using ajax, get a user status, and decide the click event : vote / login / mid-result show
	{
		var opt = $(this).find(".poll-opt").val().split(";");
		var poll_id = opt[0];
		var mid_show = opt[1];
		$.mobile.activePage.simpledialog({// simple dialog is popped up to select vote or mid-result show or delete
			'mode' : 'blank',
			'prompt' : false,
			'forceInput' : false,
			'cleanOnClose' : true,
			'useModal' : true,
			'fullHTML' : "<a rel='close' data-role='button' href=" + CI_ROOT + "poll/vote/" + poll_id 
										+ " id='simpleclose'>설문하기</a> <a rel='close' data-role='button' href=" + CI_ROOT + "poll/result_question/" +  poll_id
										 + " id='simpleclose'>중간결과보기</a>"
						+ "<a rel='close' data-role='button' href=" + CI_ROOT + "poll/delete/" + poll_id + " id='simpleclose'>설문삭제</a></a>"
		});
	}

	$('#page-all-locations').live("pageinit", function(){
		$("#add_location").click(function(){
			$.mobile.changePage(CI_ROOT + "poll/create_location", {
				role: "dialog",
				transition: 'pop',
				reverse: false,
				changeHash: false,
					
			});
		});
	});
})();
